home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 43 / Amiga Format CD43 (1999)(Future Publishing)(GB)(Track 1 of 2)[!][issue 1999-09].iso / -serious- / programming / e / speedtests / testspeed.e < prev    next >
Text File  |  1999-06-14  |  637b  |  30 lines

  1. OPT LARGE
  2. OPT MODULE
  3.  
  4. MODULE 'dos/dos','exec/memory'
  5.  
  6. CONST TICKS_PER_MINUTE=TICKS_PER_SECOND*60
  7.  
  8. DEF offset
  9.  
  10. EXPORT PROC test(proc,message,loops)
  11.   DEF t
  12.   IF offset=0 THEN offset:=time({emptyproc},loops)  /* Calculate offset */
  13.   t:=time(proc,loops)
  14.   WriteF('\l\s[40]: \r\d[3] ticks\n',message,t-offset)
  15. ENDPROC
  16.  
  17. /* Time the repeated calls, and calculate number of ticks */
  18. PROC time(proc,loops)
  19.   DEF ds1:datestamp,ds2:datestamp,i
  20.   Forbid()
  21.   DateStamp(ds1)
  22.   FOR i:=0 TO loops DO proc()
  23.   DateStamp(ds2)
  24.   Permit()
  25.   IF CtrlC() THEN CleanUp(1)
  26. ENDPROC ((ds2.minute-ds1.minute)*TICKS_PER_MINUTE)+ds2.tick-ds1.tick
  27.  
  28. emptyproc:
  29.   RTS
  30.